#
# Copyright (c) 2015 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

Import(['env', 'srcdirs', 'libdirs', 'installdir'])

localenv = env.Clone()

localenv.components = ['ipt-parser', 'common', 'sideband-parser', 'disassembler']

localenv.component_srcdirs = [ srcdirs[x] for x in localenv.components ]
localenv.component_libdirs = [ libdirs[x] for x in localenv.components ]

localenv.component_srcdirs = localenv.component_srcdirs + ['#../../kernel-module']
localenv.Append(CPPPATH = localenv.component_srcdirs)

print "INSTALLDIR " + installdir

localenv.Program(['sat-ipt-model.cpp',
                  'sat-ipt-collection.cpp',
                  'sat-ipt-task.cpp',
                  'sat-sideband-model.cpp',
                  'sat-tid.cpp',
                  'sat-caching-path-mapper.cpp',
                  'sat-helper-path-mapper.cpp',
                  'sat-ipt-instruction.cpp',
                  'sat-symbol-table-file.cpp',
                  'sat-system-map.cpp',
                  'sat-call-stack.cpp',
                  'sat-ipt-file.cpp',
                  'sat-ipt-scheduling-heuristics.cpp'],
                  LIBS = ['sat-common',
                          'sat-ipt-parser',
                          'sat-sideband-parser',
                          'sat-disassembler',
                          'capstone'],
                  LIBPATH = localenv.component_libdirs)
localenv.Program(['sat-ipt-collection-make.cpp',
                  'sat-ipt-collection.o',
                  'sat-sideband-model.o',
                  'sat-tid.o',
                  'sat-ipt-task.o',
                  'sat-ipt-file.o',
                  'sat-ipt-scheduling-heuristics.o'],
                  LIBS = ['sat-common',
                          'sat-ipt-parser',
                          'sat-sideband-parser',
                          'sat-disassembler',
                          'capstone'],
                  LIBPATH = localenv.component_libdirs)
localenv.Program(['sat-ipt-scheduling-heuristics-dump.cpp',
                  'sat-sideband-model.o',
                  'sat-tid.o',
                  'sat-ipt-scheduling-heuristics.o'],
                  LIBS = ['sat-common',
                          'sat-ipt-parser',
                          'sat-sideband-parser',
                          'sat-disassembler',
                          'capstone'],
                  LIBPATH = localenv.component_libdirs)
localenv.Program(['sat-ipt-collection-cbr.cpp',
                  'sat-ipt-collection.o',
                  'sat-sideband-model.o',
                  'sat-tid.o',
                  'sat-ipt-task.o',
                  'sat-ipt-file.o',
                  'sat-ipt-scheduling-heuristics.o'],
                  LIBS = ['sat-common',
                          'sat-ipt-parser',
                          'sat-sideband-parser',
                          'sat-disassembler',
                          'capstone'],
                  LIBPATH = localenv.component_libdirs)
localenv.Program(['sat-ipt-collection-stats.cpp',
                  'sat-ipt-collection.o',
                  'sat-sideband-model.o',
                  'sat-tid.o',
                  'sat-ipt-task.o',
                  'sat-ipt-file.o',
                  'sat-ipt-scheduling-heuristics.o'],
                  LIBS = ['sat-common',
                          'sat-ipt-parser',
                          'sat-sideband-parser',
                          'sat-disassembler',
                          'capstone'],
                  LIBPATH = localenv.component_libdirs)
localenv.Program(['sat-ipt-collection-tasks.cpp',
                  'sat-ipt-collection.o',
                  'sat-sideband-model.o',
                  'sat-tid.o',
                  'sat-ipt-task.o',
                  'sat-ipt-file.o',
                  'sat-ipt-scheduling-heuristics.o'],
                  LIBS = ['sat-common',
                          'sat-ipt-parser',
                          'sat-sideband-parser',
                          'sat-disassembler',
                          'capstone'],
                  LIBPATH = localenv.component_libdirs)

localenv.Install(installdir, [
                               'sat-ipt-collection-make',
                               'sat-ipt-model',
                               'sat-ipt-scheduling-heuristics-dump',
                               'sat-ipt-collection-cbr',
                               'sat-ipt-collection-stats',
                               'sat-ipt-collection-tasks'
                             ])
